﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace MvcMusicStore.Filter
{   [ Authorize]
    public class AuthorizationFilter : FilterAttribute,IAuthorizationFilter
    {
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext.RequestContext.HttpContext.Session.IsNewSession)
            {

            }
        
            MembershipUser user=  Membership.GetUser();
            if (user == null)
            {

            }
            else
            {
                string[] roles = Roles.GetRolesForUser(user.UserName);

                System.Diagnostics.Trace.WriteLine(roles);
            }
            
            //throw new NotImplementedException();
        }
    }
}